function trim(val)
 {
	return val.replace(/(\s*$)/g, "");
}
function backa()
{
	parent.location.href='index.jsp';
	self.location='modifyBasicInfo.jsp';
}

function click1()
{
	document.getElementById("modify").src="modifyBasicInfo.jsp";
	document.getElementById("button1").className="selectbtn";
	document.getElementById("button2").className="";
	document.getElementById("button3").className="";
}
function click2()
{
	document.getElementById("modify").src="modifyPwInfo.jsp";
	document.getElementById("button1").className="";
	document.getElementById("button2").className="selectbtn";
	document.getElementById("button3").className="";
}
function click3()
{
	document.getElementById("modify").src="modifyPwcInfo.jsp";
	document.getElementById("button1").className="";
	document.getElementById("button2").className="";
	document.getElementById("button3").className="selectbtn";
}
function checkform1()
{
	 var real_name = document.getElementById("real_name");
	 if(real_name == null || real_name.value == "")
	 {
	 	alert('真实姓名不能为空！');
	 	document.getElementById("real_name").focus();
	  return false;
	 }
	 
	 	var cellphone = document.getElementById("cellphone");
		var myreg1=/^[1][\d]{10}$/;
		if(cellphone !=null && cellphone.value !="")
		{
			if(!myreg1.test(cellphone.value))
			{
			   alert('请输入有效的手机号码！');
			     document.getElementById("cellphone").focus();
			   return false;
			}
		}
	 
	 var email = document.getElementById("email");
	 var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	 if(email !=null && email.value !="")
	 {
	   if(!myreg.test(email.value))
		 {
	     alert('请输入有效的E_mail！');
	     document.getElementById("email").focus();
	     return false;
		 }
		}
		var msn = document.getElementById("msn").value;
		if (msn.length!=0) {
          if (!myreg.test(msn))
                {
					alert("提示：您填写的msn无效，请填写一个有效的msn");
					msn.focus();
					return false;
                }
          }

	
		
		var phone = document.getElementById("phone");
		var myreg2 =/^((0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/;
		if(phone !=null && phone.value !="")
		{
			if(!myreg2.test(phone.value))
			{
			   alert('请输入有效的电话号码！');
			     document.getElementById("phone").focus();
			   return false;
			}
		}
		var fax = document.getElementById("fax");
		if(fax !=null && fax.value !="")
		{
			if(!myreg2.test(fax.value))
			{
			   alert('请输入有效的传真号码！');
			   document.getElementById("fax").focus();
			   return false;
			}
		}
		var remark = document.getElementById("remark");
		if(remark !=null && remark.value !="")
		{
			if(remark.length>50)
			{
			   alert('备注字数不能大于50');
			   document.getElementById("remark").focus();
			   return false;
			}
		}
		
		document.addForm.submit();
}

function checkPW(){
	  	  
		Ti_adminInfo.checkOldPW(document.getElementById("user_id").value,document.getElementById("old_passwd").value,function(data){
						
			var old_passwd = document.getElementById("old_passwd").value;
			if(old_passwd == null || old_passwd == ""){
		  	alert("原密码不能为空!");
		  	document.pwdForm.old_passwd.focus();
		  	return false;
		  }
		  
			if(data == 0){
				alert("你输入的原密码不正确!");
				document.getElementById("old_passwd").value = "";
				document.getElementById("old_passwd").focus();
				return false;
			}
			
			var new_passwd = document.getElementById("new_passwd").value;
			var passwordLowcase = new_passwd.toLowerCase();
			var az = 'abcdefghijklmnopqrstuvwxyz';
			var chemNew_passwd = /^(([A-Z])+|([a-z]+)|(\d+)){6,20}$/;
			
		  if(null == new_passwd || new_passwd == ""){
		  	alert("新密码设定不能为空!");
		  	document.pwdForm.new_passwd.focus();
		  	return false;
		  }else if(!chemNew_passwd.test(new_passwd)||new_passwd.length>20){
		  	alert("新密码设定为6-20个字符且只允许输入数字和英文字母!");
		  	document.pwdForm.new_passwd.focus();
		  	return false;
		  }else if('0123456789'.indexOf(passwordLowcase) > -1 || '9876543210'.indexOf(passwordLowcase) > -1) {
				alert("请不要使用连续的数字做为密码!");
				document.pwdForm.new_passwd.focus();
				return false;
			}
			//连续的大写字母
			else if(new_passwd.toUpperCase() == new_passwd && (az.indexOf(passwordLowcase)>-1 || az.indexOf(passwordLowcase.split('').reverse().join(''))>-1)){
				alert("请不要使用连续的大写字母做为密码!");
				document.pwdForm.new_passwd.focus();
				return false;
			}
			//连续的小写字母
			else if(passwordLowcase == new_passwd && (az.indexOf(passwordLowcase)>-1 || az.indexOf(passwordLowcase.split('').reverse().join(''))>-1)) {
				alert("请不要使用连续的小写字母做为密码!");
				document.pwdForm.new_passwd.focus();
				return false;
			}
			//相同的数字
			else if(/^(\d)\1+$/.test(passwordLowcase)) {
				alert("请不要使用相同的数字做为密码!");
				document.pwdForm.new_passwd.focus();
				return false;
			}
			//相同的字母
			else if(/^([a-zA-Z])\1+$/.test(passwordLowcase)) {
				alert("请不要使用相同的字母做为密码!");
				document.pwdForm.new_passwd.focus();
				return false;
			}
			else if(old_passwd == new_passwd){
				alert("原密码与新密码一致，无需修改！");
				return false;
		    }
		  
		  var sure_passwd = document.getElementById("sure_passwd").value;
		  if(null == sure_passwd || sure_passwd == ""){
		  	alert("确认密码不能为空!");
		  	document.pwdForm.sure_passwd.focus();
		  	return false;
		  }else if(new_passwd != sure_passwd){
		  	alert("两次输入的密码不一致!");
		  	document.pwdForm.sure_passwd.focus();
		  	return false;
		  }
	  	document.pwdForm.submit();
		});
		
}


function check_passwd_ques(state){
	var passwd_ques = document.getElementById("passwd_ques").value;
	if(state)
	{
		
	}
	else
	{
		if(passwd_ques==null || passwd_ques=="")
		{
			alert('你的密码提示问题为空,请设置密码提示问题和答案！');
			document.getElementById("passwd_ques").value = "";
			document.passwd_quesForm.passwd_ques.focus();
		}
	}
}

function checkAnswer1(){
	Ti_adminInfo.checkPasswdAnswer(document.getElementById("user_id").value,document.getElementById("passwd_answer").value,function(data){
			
			var passwd_answer = document.getElementById("passwd_answer").value;
		  if(null == passwd_answer || passwd_answer == ""){
		  	alert("密码提示问题答案不能为空!");
		  	document.passwd_quesForm.passwd_answer.focus();
		  	return false;
		  }
			
			if(data == 0){
				alert('你的原密码提示答案不正确！请重新回答');
				document.getElementById("passwd_answer").value = "";
				document.getElementById("passwd_answer").focus();
				return false;
			}
			window.location.href='modifyPwcInfo2.jsp';
		});
}

function checkAnswer(){
	
		var passwd_ques = document.getElementById("passwd_ques").value;
		if(null == passwd_ques || passwd_ques == ""){
	  	alert("密码提示问题不能为空!");
	  	document.passwd_quesForm.passwd_ques.focus();
	  	return false;
	  }
		
	  var passwd_answer = document.getElementById("passwd_answer").value;
	  var passwd_answer1 = document.getElementById("passwd_answer1").value;
	  if(null == passwd_answer || passwd_answer == ""){
	  	alert("密码提示问题答案不能为空!");
	  	document.passwd_quesForm.passwd_answer.focus();
	  	return false;
	  }
	  if(null == passwd_answer1 || passwd_answer1 == ""){
	  	alert("确认密码提示问题答案不能为空!");
	  	document.passwd_quesForm.passwd_answer1.focus();
	  	return false;
	  }
	  if(passwd_answer != passwd_answer1){
	  	alert("两次输入的密码提示问题答案不一致!");
	  	document.passwd_quesForm.passwd_answer1.focus();
	  	return false;
	  }
	  document.passwd_quesForm.submit();
}

